#pragma once
#include "Scanner.h"
#include "Token.h"
#include "Parameter.h"
#include "Predicate.h"
#include "Rule.h"
#include <iostream>
#include <map>
#include <vector>

using namespace std;

class DatalogProgram {
	public:
		DatalogProgram(char*);
		~DatalogProgram() {
			delete scan;
			delete nextToken;
			delete currentPredicate;
			delete currentRule;
		}

		bool isDatalogProgram();
		bool isSchemeList();
		bool isScheme();
		bool isFactList();
		bool isFact();
		bool isRuleList();
		bool isRule();
		bool isQueryList();
		bool isQuery();
		bool isPredicateList(int which_list);
		bool isPredicate(int which_list);
		bool isParameterList();
		bool isParameter();
		bool matchTokenType(string type);
		bool matchTokenType(string type1, string type2);
		bool peekTokenType(string type);
		void makeParameter();
		void makePredicate();
		void makeRule();
		string toString();
		bool fail;

		string schemesString();
		string factsString();
		string rulesString();
		string queriesString();
		string domainString();
	private:
		DatalogProgram();

		Scanner* scan;
		Token* nextToken;
		Predicate* currentPredicate;
		Rule* currentRule;
		vector <Predicate> schemes;
		vector <Predicate> facts;
		vector <Rule> rules;
		vector <Predicate> queries;
		map <string, Token> domain;

};